import request from './request'

/**
 * 根据Id获取用户信息
 * @param {*} id
 * @returns
 */
export const getUserById = (id) => {
  return request({
    url: `/user/${id}`,
    method: 'GET'
  })
}
/**
 * 获取用户列表
 * @param {*} params
 * @returns
 */
export const getUserList = (params) => {
  return request({
    url: '/user/list',
    params
  })
}

/**
 * 添加用户信息
 * @param {*} data
 * @returns
 */
export const addUser = (data) => {
  return request({
    url: '/user/add',
    method: 'post',
    data
  })
}

// 修改用户信息
export const editUser = (data) => {
  return request({
    url: '/user/update',
    method: 'put',
    data
  })
}

// 根据Id删除用户
export const deleteUser = (id) => {
  return request({
    url: `/delete/user/${id}`,
    method: 'delete'
  })
}

/**
 * 修改用户状态
 * @param {*} data
 * @returns
 */
export const updateUserStatus = (data) => {
  return request({
    url: '/update/user_status',
    method: 'patch',
    data
  })
}

/**
 * 修改头像
 * @param {*} formData
 * @returns
 */
export const updateAvatar = (formData) => {
  return request({
    url: '/update/avatar',
    method: 'patch',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  })
}

/**
 * 获取用户列表
 * @param {*} params
 * @returns
 */
export const getUserListDel = (params) => {
  return request({
    url: '/user/list/delete',
    params
  })
}

// 根据Id恢复用户
export const restoreUser = (id) => {
  return request({
    url: `restore/user/${id}`,
    method: 'patch'
  })
}